package Tree;

public class _559_MaximumDepthofN_aryTree {
    int mdepth = 0;
    public int maxDepth(Node root) {
        helper(root, 1);
        return mdepth;
    }

    public void helper(Node root, int depth) {
        if (root != null) {
            if (depth > mdepth) {
                mdepth = depth;
            }
            for (Node node : root.children) {
                helper(node, depth + 1);
            }
        }
    }
}
